package com.leaves.leetcode.array.t18_4Sum;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.leaves.leetcode.UnitTesting;
import java.util.List;

public class T18Main extends UnitTesting<Object[], List<List<Integer>>> {

    Solution solution = new Solution();

    @Override
    protected void generateTestData() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            testDataList.add(createTestData(
                    new Object[]{new int[]{1, 0, -1, 0, -2, 2}, 0},
                    objectMapper.readValue("[[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]", new TypeReference<List<List<Integer>>>() {
                    }))
            );
            testDataList.add(createTestData(new Object[]{
                            new int[]{2, 2, 2, 2, 2}, 8},
                    objectMapper.readValue("[[2,2,2,2]]", new TypeReference<List<List<Integer>>>() {
                    }))
            );
            testDataList.add(createTestData(new Object[]{
                            new int[]{0,0,0,1000000000,1000000000,1000000000,1000000000}, 1000000000},
                    objectMapper.readValue("[[0,0,0,1000000000]]", new TypeReference<List<List<Integer>>>() {
                    }))
            );

        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public List<List<Integer>> run(Object[] inputData) {
        int[] nums = (int[]) inputData[0];
        int target = (int) inputData[1];
        return solution.fourSum(nums, target);
    }

}
